﻿<?php
header("Content-Type: text/html;charset=utf-8");
require_once '../swiftmailer-master/lib/swift_required.php';
require_once '../model/PdoMySQL.class.php';
require_once '../model/config.php';

require_once '../model/pwd.php';
$username=$_REQUEST["username"];
echo $username;
exit;
    create();

function create(){
    $username=$_GET["username"];
    $password=base64_encode($_GET["password"]);
    $password=$_GET["password"];
    $email=$_GET["email"];
    $mobilephone=$_GET["mobilephone"];
    $table=$_GET["tablename"];
    $preusername=$_GET['preusername'];
    if (!isset($_GET["username"]) || empty($_GET["username"])
        || !isset($_GET["password"]) || empty($_GET["password"])
        || !isset($_GET["email"]) || empty($_GET["email"])
        ||!isset($_GET["mobilephone"]) || empty($_GET["mobilephone"])
        ||!isset($_GET["tablename"]) || empty($_GET["tablename"])) {
        echo "参数错误，用户信息填写不全";
        return;
    }
    else{
        $pdo=new PdoMySQL();
        $sql="UPDATE {$table} SET username='{$username}',password='{$password}',email='{$email}',mobilephone='{$mobilephone}' WHERE username='{$preusername}';";
        $stmt=$pdo->query($sql);
        if($stmt==1){
            echo '<script language="JavaScript">window.alert("信息更新成功"),location.href="../admin/account.php";</script>';
        }else{
            echo '<script language="JavaScript">window.alert("请重新修改信息"),location.href="../admin/account.php";</script>';

        }
    }

//if ($_SERVER["REQUEST_METHOD"] == "POST"){
//	create();
//}
//function create(){
//	$username=$_POST["username"];
//	$password=base64_encode($_POST["password"]);
//	$usertype=$_POST["usertype"];
//	$email=$_POST["email"];
//	$mobilephone=$_POST["mobilephone"];
//	if (!isset($_POST["username"]) || empty($_POST["username"])
//		|| !isset($_POST["password"]) || empty($_POST["password"])
//		|| !isset($_POST["usertype"]) || empty($_POST["usertype"])
//		|| !isset($_POST["email"]) || empty($_POST["email"])
//		||!isset($_POST["mobilephone"]) || empty($_POST["mobilephone"]) ) {
//		echo "参数错误，用户信息填写不全";
//		return;
//	}
//	else{
//	$pdo=new PdoMySQL();
//	$sql="UPDATE projector SET username='{$username}',password='{$password}',email='{$email}',mobilephone='{$mobilephone}' WHERE username='{$username}';";
//	echo $sql;
//	$stmt=$pdo->execute($sql);
//	if($stmt==1){
//		$result="信息更新成功";
//	}else{
//		$result="请修改信息，再提交";
//		}
//	}
//	echo $result;
}
